package org.wxd.common.utils;

import com.google.common.collect.Sets;

import java.util.*;

/**
 * Created by wangxd on 2017/2/9.
 */
public class PropertiesOrdered extends Properties {

    private static final long serialVersionUID = -4627607243846121965L;

    private final LinkedHashSet<Object> keys = Sets.newLinkedHashSet();

    public Enumeration<Object> keys() {
        return Collections.enumeration(keys);
    }

    public Object put(Object key, Object value) {
        keys.add(key);
        return super.put(key, value);
    }

    public Set<Object> keySet() {
        return keys;
    }

    public Set<String> stringPropertyNames() {
        Set<String> set = Sets.newLinkedHashSet();
        this.keys.forEach(k -> set.add((String) k));
        return set;
    }
}
